package com.example.springbootdemo.infra.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器，处理项目中抛出的业务异常
 */
@RestControllerAdvice
public class GlobalExceptionHandler {


    /**
     * 处理sql异常
     * @param ex
     * @return
     */
    /*@ExceptionHandler
    public Result exceptionHandler(SQLIntegrityConstraintViolationException ex){
        String errorMessage = ex.getMessage();
        if (errorMessage.contains("Duplicate entry")){
            String[] message = errorMessage.split(" ");
            //获取重复姓名
            String name = message[2];
            String msg=name+ MessageConstant.ALREDAY_EXIST;
            return Result.error(msg);
        }
        return Result.error(MessageConstant.UNKNOWN_ERROR);

    }*/

}
